<?
include("sqlconnect.php");

//$parameter='allcategories';
//$parameter = 'listbrands';
//$selected_category= 'Consumer Electronics';

if(isset($_POST['ld']))
{
$parameter= $_POST['ld'];
}else {
		$parameter= $_GET['ld'];
		}

if((strcasecmp('allcategories',$parameter)) == 0)
{
	$query= "SELECT * FROM top_category_list ";
	$result= mysql_query($query) or die(mysql_error());
	$i=0;
	while ($row = mysql_fetch_object($result))
	{
		$category_array[$i]=$row->category_name;
		$i++;
	}
	//header('Content-Type:text/xml');
	//echo '<?xml version="1.0" encoding="UTF-8"// <brandlist>';
	
	for($c=0;$c<$i;$c++)
	{
		echo $category_array[$c].'#';
	}
	
}


if($parameter == 'listbrands')
{
	$selected_category = $_GET['cat'];
	$query= "SELECT * FROM category_list where category_name = '".$selected_category."'";
	$result= mysql_query($query) or die(mysql_error());
	$i=0;
	while ($row = mysql_fetch_object($result))
	{
		$brand_array[$i]=$row->brand_associated;
		$i++;
	}

	$brand_array[$i] = 'All';
	$i++;
	//header('Content-Type:text/xml');
	//echo '<?xml version="1.0" encoding="UTF-8"';
	for($c=0;$c<$i;$c++)
	{
		echo $brand_array[$c].'#';
	}
}

if($parameter == 'listproducts')
{
	$selected_brand = $_GET['selbrand'];
	
	$query= "SELECT * FROM product where brand_name = '".$selected_brand."'";
	$result= mysql_query($query) or die(mysql_error());

	$i=0;
	while ($row = mysql_fetch_object($result))
	{
		$product_array[$i]=$row->product_name;
		$i++;
	}

	for($c=0;$c<$i;$c++)
	{

		echo $product_array[$c].'#';

	}


}




?>